﻿@using System.Web.Optimization
@inherits VocaDb.Web.Code.VocaDbPage<VocaDb.Model.DataContracts.Users.UserBaseContract>

@{
	PageProperties.Title = "Entry edits - " + Model.Name;
	ViewBag.Parents = new[] { 
		Html.ActionLink("Users", "Index"), 
		Html.ActionLink(Model.Name, "Details", new { id = Model.Id }) 		
	};
}

<!-- Binding context: ActivityEntryListViewModel -->

<ul class="nav nav-pills">
	<li data-bind="css: { active: editEventFilter_all }">
		<a href="#" click="{{ function() { editEventFilter_all(true); } }}">All edits</a>
	</li>
	<li data-bind="css: { active: !editEventFilter_all() }">
		<a href="#" click="{{ function() { editEventFilter_all(false); } }}">Only additions</a>
	</li>
</ul>

<div data-bind="foreach: entries, show" class="js-cloak">
	@ActivityfeedHelpers.ActivityEntryKnockout("$parent.getEntryTypeName", "$parent.getActivityFeedEventName", "$parents[1].getChangedFieldNames", true)
</div>

<hr />
<h3>
	<a href="#" data-bind="click: loadMore">View more</a>
</h3>

@section BodyScripts {
	@Scripts.Render("~/bundles/ActivityEntry/Index")
	<script type="text/javascript">
		$(function () {

			moment.locale('@Culture');
			ko.punches.enableAll();

			var urlMapper = new vdb.UrlMapper("@RootPath");
			var resourceRepo = new vdb.repositories.ResourceRepository('@RootPath');
			var languageSelection = '@UserContext.LanguagePreference';
			var cultureCode = '@UICulture';
			var userId = @Model.Id;
			var editEvent = @ToJS((int?)ViewBag.EditEvent);

			var vm = new vdb.viewModels.activityEntry.ActivityEntryListViewModel(urlMapper, resourceRepo, languageSelection, cultureCode, userId, editEvent);
			ko.applyBindings(vm);

		});
	</script>
}